﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="ie-comp|ie-stand|webkit">
    <title><?php echo $settings_site->site_name;?></title>
    <link id="easyuiTheme" rel="stylesheet" type="text/css" href="<?php echo base_url().'data/themes/default/easyui.css';?>">
    <link rel="stylesheet" type="text/css" href="<?php echo base_url().'data/themes/icon.css';?>">
    <link rel="stylesheet" type="text/css" href="<?php echo base_url().'data/other/css/custom_icon.css';?>">
    <link rel="stylesheet" type="text/css" href="<?php echo base_url().'data/uploadify/uploadify.css'?>">

    <script type="text/javascript" src="<?php echo base_url().'data/jquery.min.js';?>"></script>
    <script type="text/javascript" src="<?php echo base_url().'data/jquery.easyui.min.js';?>"></script>

    <script type="text/javascript" src="<?php echo base_url().'data/locale/easyui-lang-zh_CN.js';?>"></script>
    
	<script src="<?php echo base_url().'data/uploadify/jquery.uploadify.min.js'?>" type="text/javascript"></script>
    <script type="text/javascript" src="<?php echo base_url().'data/datagrid-groupview.js';?>"></script>
	<script>
	//给编辑器赋路径值
    window.UEDITOR_HOME_URL = "<?php echo base_url()?>data/ueditor/";
    window.PROJECT_PATH = '<?php echo base_url()?>';
	window.user_agent = '<?php echo $this->agent->browser();?>';
    </script>
    <script type="text/javascript" src="<?php echo base_url().'data/other/js/function.js';?>"></script>
    <script type="text/javascript" src="<?php echo base_url().'data/AjaxLongPolling.js';?>"></script>
    <script type="text/javascript" src="<?php echo base_url().'data/other/js/att.js';?>"></script>
    <script type="text/javascript" charset="utf-8" src="<?php echo base_url().'data/ueditor/ueditor.config.js';?>"></script>
    <script type="text/javascript" charset="utf-8" src="<?php echo base_url().'data/ueditor/ueditor.all.min.js';?>"></script>   
    <script type="text/javascript" charset="utf-8" src="<?php echo base_url().'data/other/js/selectuser.js';?>"></script>
    <script>
		function endload(){			
			check_new_sms_ajax();//检查新消息，在AjaxLongPolling中
			online();//每隔3分钟更行一次在线人数
		}
	</script>
    <style>
	body{
	   -moz-user-select: none; /*火狐*/   
	   -webkit-user-select: none;  /*webkit浏览器*/   
	   -ms-user-select: none;   /*IE10*/   
	   -khtml-user-select: none; /*早期浏览器*/   
	   user-select: none;
	}
	
	/*导航菜单中树的自定义样式*/   
	.workManageTree li .tree-node{
		-moz-border-radius: 5px 5px 5px 5px;
		-webkit-border-radius: 5px 5px 5px 5px;
		border-radius: 5px 5px 5px 5px;
		padding:5px 0;
	}

	.textbox{
		height:20px;
	}
	
	/*自定义datagrid样式 tab_a*/   
	.tab_a .datagrid-header td, .tab_a .datagrid-body td, .tab_a .datagrid-footer td {
		border-width: 0 0 1px 0;
	}
	.tab_a .datagrid-header-row, .tab_a .datagrid-row {
		height: 35px;
	}
	.tab_a .datagrid-header-check, .tab_a .datagrid-cell-check{
		width:40px;
	}

	</style>
</head>
<body onLoad="endload()">
<div class="easyui-layout" fit="true" style="background: url(<?php echo base_url().'data/other/images/header.jpg';?>) no-repeat center top;">
	<!--顶部框架-->
    <div data-options="region:'north'" style="height:60px; border:0px; overflow:hidden; background-color:transparent;">
    	<div style="float:left; font-family:微软雅黑; font-size:21px; padding:16px 0 0 20px; ">
        	<?php echo $settings_site->site_name;?>
        </div>
        <div style=" position:absolute; top:7px; right:30px;"><a class="easyui-linkbutton" data-options="plain:true" onClick="javascript:dialog_public('在线人员','app/online_view')"><span id="online">--</span>人在线</a></div>
        <div style=" position:absolute; top:30px; right:30px;">
        	<div style="float:right;"><a class="easyui-linkbutton" data-options="plain:true" onClick="quit();">退出</a></div> 
            <div style="float:right; margin:0 10px 0 0;"><a class="easyui-linkbutton" data-options="plain:true" onClick="tabs_action('个人资料','systemmanage/personal_info','icon-man')">用户：<?php echo $this->session->userdata('user_name').' &raquo; 角色：'.$this->session->userdata('role_name').' &raquo; 部门：'.$this->session->userdata('dept_name');?></a></div>
        </div>       
    </div>    
    
    <!--底部框架-->
    <div data-options="region:'south'" style="height:30px; background-color:#d2e0f2; color:#999; text-align:center; font-size:12px; font-family:微软雅黑; line-height:23px; overflow:hidden;">&copy; 2014 远景软件 Authorize <?php echo $settings_site->site_name;?>
    
    	<!--邮箱模块查看发件箱中接收人情况的弹出窗口容器-->
    	<div id="read_status"><table id="readStatusView"></table></div>
        
        <!--公共弹出窗口容器-->
    	<div id="dialog_custom_box"></div>
        
        <!--文档在线编辑窗口公共容器-->
    	<div id="window_custom_box"></div>
        
        <!--选择用户容器-->
        <div id="selectuser_dd" class="easyui-dialog" style="width:450px;height:400px;padding:5px;" data-options="iconCls:'icon-user',resizable:true,modal:true,closed: true">
            <div class="easyui-layout" data-options="fit:true">
                <div data-options="region:'east',split:true" style="width:210px">
                	<div id="selectuser_list" class="easyui-datagrid" title="单击部门名称或勾选" border="false"></div>
                </div>
                <div data-options="region:'center'" style="padding:10px;">
                    <ul id="selectuser_tree"></ul>
                </div>
                <div data-options="region:'south'" style="text-align:right; height:40px; padding-top:5px; border-width:1px 0 0 0; overflow:hidden">
                    <a class="easyui-linkbutton" data-options="iconCls:'icon-ok'" href="javascript:void(0)" onClick="javascript:$('#selectuser_dd').dialog('close')" style="width:80px">确定</a>
                    <a class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" href="javascript:void(0)" onClick="javascript:clearuser()" style="width:80px">清空</a>
                </div>
            </div>
        </div>
        
        <!--短消息提示音-->
        <div id="messagemp3"></div>
    </div>
    
    <!--左侧导航框架-->
    <div data-options="region:'west',split:true" title="导航菜单" style="width:180px;">
        <div class="easyui-accordion" fit="true" border="false">
        	<?php //$this->acl->show_left_menus(); ?>
            <?php	
            if($menus):
                foreach($menus as $menu):
                ?>
                <div title="<?php echo $menu['text'];?>" data-options="iconCls:'<?php echo $menu['iconCls'];?>'" style="overflow:auto;padding:10px;">
                    <ul class="workManageTree" data-options="url:'<?php echo base_url('app/menus/'.$menu['id']);?>'"></ul>
                </div>
                <?php
                endforeach;
			else: 
				echo "<div style='padding:5px;'>当前角色权限为空！<br>请联系管理员添加相应权限！</div>";
            endif;?>                
        </div>        
    </div>
    
    <!--右侧内容框架-->
    <div data-options="region:'center'" border="false" style="background-color:transparent;">
        <div id="main-tab" class="easyui-tabs" data-options="tools:'#tab-tools',fit:true">
            <div title="首页" data-options="iconCls:'icon-house'" style="padding:10px" >
            </div>
        </div>
        <div id="tab-tools" style="border-right-width: 0;">                
            <a title="关闭所有打开的面板" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-application-delete',position:'left'" onClick="mainremovePanel()"></a>
        </div>
    </div>
</div>
<div id="attachmentIFrame"></div> 
<script>

//导航菜单动作
$('.workManageTree').tree({
	onLoadSuccess:function(node, data){
		$('.workManageTree').tree('collapseAll');
	},
	onClick: function(node){		
		if(!$('this').tree('isLeaf',node.target)){
			$(this).tree(node.state === 'closed' ? 'expand' : 'collapse', node.target);  
			//node.state = node.state === 'closed' ? 'open' : 'closed'; //双击时需要启用该行
		}
		if(node.attributes.url.length > 0){
			/**当前的tab 是否存在如果存在就 自动选择 否则 创建新的tab**/
			tabs_action(node.text,node.attributes.url,node.iconCls);
		}
	}
});

//公共tabs面板函数
function tabs_action(title,url,icon){
	if ($('#main-tab').tabs('exists', title)){
		$('#main-tab').tabs('select', title); 
	}else{
		$("#main-tab").tabs('add',{					
			title: title,
			href: '<?php echo base_url();?>'+url,
			selected: true,
			closable:true,
			iconCls:icon
		});
	}
}


//关闭带编辑器tabs的面板时，必须销毁该面板中的编辑器，否则再次打开时无法使用
$('#main-tab').tabs({
	onBeforeClose: function(title){
		if(title == '新邮件'){
			//$("#email_file_upload").hide();　
			$('#email_file_upload').uploadify("destroy");
			UE.getEditor('email_editor').destroy();
		}
		if(title == '新通告'){
			UE.getEditor('notify_editor').destroy();	
		}
	}
});

//退出当前系统
function quit(){
	$.messager.confirm('确认', '你要退出当前系统吗?', function(r){
		if (r){
			//alert('confirmed: '+r);
			window.location='<?php echo base_url('login/quit')?>'
		}
	});
}



//用户选择窗口构造方法，由于多个功能模块需要使用该方法，所以放在首页
var url;
$('#selectuser_tree').tree({
	url:'<?php echo base_url('systemmanage/dept_data')?>',
	method:'post',
	checkbox:true,
	fit:true,                    
	onSelect : function(node) {
		//返回树对象
		var tree = $(this).tree;
		//选中的节点是否为叶子节点,如果不是叶子节点,清除选中
		var isLeaf = tree('isLeaf', node.target);
		if (!isLeaf) {
			//清除选中
			$('#selectuser_tree').tree('toggle',node.target);
			//$.messager.alert('警告','请选择子部门!','warning');
		}else{			
			//$('#selectuser_tree').tree({
				//onClick: function(node){
					//alert(node.text);  // alert node text property when clicked
					$('#selectuser_list').datagrid({
						url:'<?php echo base_url('systemmanage/user_data');?>/'+node.id,
						title:node.text+' 用户列表',
						showHeader:false,
						loadMsg:'加载中',
						nowrap:false,
						fit:true,
						fitColumns:true,
						border:false,
						columns:[[
							{field:'user_name',width:180,align: 'center'}
						]],
						onClickRow:function(index,data){
							if(data.id){   /*如果返回列表，则执行插入用户和选中动作，否则不许插入并取消选中*/
								click_user(data);	
							}else{
								$('#selectuser_list').datagrid("unselectRow", index);//
							}
						},
						onLoadSuccess:function(data){//当数据加载成功时触发 
							if(data.total){/*如果查询的用户列表不为0行，则执行插入和选中动作，否则在用户列表位置插入‘暂无用户’提示*/
								begin_set();
							}else{
								$('#selectuser_list').datagrid('appendRow',{
									user_name: '暂无用户'
								});
							}
						}
					});
				//}
			//});
		}
	},
	onCheck:function(node, checked){ 
		if(checked){
			$.get("<?php echo base_url('selectuser/getcheckeduser');?>/"+node.id,function(result){
				add_all(result);
			},'json');
		}else{
			$.get("<?php echo base_url('selectuser/getcheckeduser');?>/"+node.id,function(result){
				del_all(result);	
			},'json');
		}
	},
	onLoadSuccess:function(node, data){
		//$('#selectuser_tree').tree('collapseAll');
	}		
});


//显示在线人员数
function online(){  
	$("#online").load("<?php echo base_url();?>app/online?_="+GetRandomNum());
	setTimeout("online()",180000);
}

//公共dialog弹出窗口方法
function dialog_public(title,url){
	var w = arguments[2] ? arguments[2] : 600;
	var h = arguments[3] ? arguments[3] : 500;
	var on = arguments[4] ? arguments[4] : '';
	$('#dialog_custom_box').dialog({
		title: title,
		width: w,
		height: h,
		closed: false,
		cache: false,
		href: pro_path+url,
		modal: true,
		onClose:function(){
			//关闭该对话框时执行的语句
			on;
		}
	});
}


//用uploadify组件上传附件是屏蔽修改标题为#号的操作
/*
var oldTitle = document.title;
try{
	document.attachEvent('onpropertychange',function(){
		if(document.title != oldTitle){
			document.title = oldTitle;
		}
	})
}catch(e){}
*/
</script>
</body>
</html>